package seed_commerce

import (
	"fmt"
	"gitee.com/theegg/go-brick/app/model/commerce/goods"
	"github.com/xormplus/xorm"
	"time"
)

func InitGoodsSeed(db *xorm.Engine) {
	items := make(map[int]goods.Goods)
	items[1] = goods.Goods{
		SetId:     1,
		SubTitle:  "宝石蓝#512G",
		IsDefault: 1,

		MarketPrice: 623000,
		UnitPrice:   349000,
		Inventory:   200,
		ImageCover:  "",
		ImageList:   "",

		IsHot:        1,
		IsSale:       0,
		SaleDiscount: 0,

		Status:     1,
		AddTime:    time.Now().Unix(),
		UpdateTime: 0,
	}

	items[2] = goods.Goods{
		SetId:     1,
		SubTitle:  "宝石蓝#256G",
		IsDefault: 1,

		MarketPrice: 623000,
		UnitPrice:   349000,
		Inventory:   200,
		ImageCover:  "",
		ImageList:   "",

		IsHot:        1,
		IsSale:       0,
		SaleDiscount: 0,

		Status:     1,
		AddTime:    time.Now().Unix(),
		UpdateTime: 0,
	}

	count := 0
	errCount := 0
	for _, item := range items {
		_, err := db.Insert(item)
		if err != nil {
			fmt.Println(err.Error())
			errCount++
		} else {
			count++
		}
	}

	fmt.Printf("%5s|%25s|%10d|%8d|\n", "", "goods", count, errCount)
}
